package com.yra.service.impl;

import com.yra.domain.Carousel;
import com.yra.mapper.CarouselMapper;
import com.yra.service.CarouselService;
import com.yra.util.PageQueryUtil;
import com.yra.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: yrq
 * @Date: Create in 9:35 2019/12/17
 */
@Service
public class CarouselServiceImpl implements CarouselService {
    @Autowired
    private CarouselMapper carouselMapper;

    @Override
    public PageResult getCarouselPage(PageQueryUtil pageQueryUtil) {
        List<Carousel> carouselList = carouselMapper.carouselPageList(pageQueryUtil);
        int total = carouselMapper.getTotalCarousels(pageQueryUtil);
        PageResult pageResult = new PageResult(carouselList, total, pageQueryUtil.getLimit(), pageQueryUtil.getPage());
        return pageResult;
    }

    @Override
    public Boolean insertCarousel(Carousel carousel) {
        return carouselMapper.insertCarousel(carousel)>0;
    }

    @Override
    public Boolean updateCarousel(Carousel carousel) {
        return carouselMapper.updateCarousel(carousel)>0;
    }

    @Override
    public Boolean deleteCarouselByIds(int[] ids) {
        return carouselMapper.deleteCarouselByIds(ids)>0;
    }

    @Override
    public List<Carousel> queryCarouselForIndex(int limit) {
        return carouselMapper.queryCarouselForIndex(limit);
    }
}
